// https://blog.csdn.net/kingAn123/article/details/99602653
// 节流函数
export default function Throttle(func: any, wait: number, trailing: number) {
    let timer: any = null
    let start = 0
    return function () {
        let now: any = new Date()
        if ((now - start) >= wait) {
            timer && clearTimeout(timer)
            timer = null
            start = now
            return func()
        } else if (!timer && trailing) {
            timer = setTimeout(() => {
                timer = null
                return func
            }, wait)
        }
    }
}
